package ac.manchester.cs.afzal.autoservd.semantic_classes;

import ac.manchester.cs.afzal.autoservd.Descriptors.Descriptor_Processor;
import ac.manchester.cs.afzal.autoservd.Descriptors.Descriptors_Ngrams;
import ac.manchester.cs.afzal.autoservd.interactions.Interactions;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

    public static void main(String[] args)
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String input;
        try
        {
            System.out.println(
                    "*****************************************************");
            System.out.print(
                    "Please Choose among following options:\n" +
                    " 1.  Create Semantic Classes \n" +
                    " 2.  Populate Semantic Classes \n" +

                    "*****************************************************\n\n" +
                    " 3.  Find overlapping semantic class instances \n" +
                    " 4.  Find overlap between semantic class instances and terms \n" +
                    " 5.  Find overlap between semantic class instances and mygrid terms \n" +
                    " 5a. Find overlap between semantic class instances and Resource Descriptors \n" +

                    "*****************************************************\n" +

                    " 6.  Extract Service Descriptors from text files  \n" +
                    " 6a. Extract Top 300 terms from Results_Final \n" +

                    "*****************************************************\n" +

                    " 7.  Extract Manually filtered Descriptors from Resource\\StartList.txt \n" +
                    " 7a. Extract Descriptors from temp table and export in __bioinformatics_service_descriptors \n" +
                    " 7b. Export the Bioinformatics descriptors table in xml format \n" +

                    "*****************************************************\n" +

                    " 8.  Convert Service Descriptors to Ngrams \n" +
                    " 8a. Convert Sentence Descriptors to Ngrams \n" +

                    "*****************************************************\n" +

                    " 9.  Develop Semantic Network of Bioinformatics Resources \n" +
                    " 9a. Find overlaps between Sentence and Service Descriptors  \n" +

                    " Enter number to continue or 'e' to exit : ");
            
            input = in.readLine();
            input = input.trim();

            if (input.equals("1"))
            {
                Semantic_Class_Instances sci = new Semantic_Class_Instances();
                sci.create_semantic_class_tables();
            }
            else if (input.equals("2"))
            {
                Semantic_Class_Instances sci = new Semantic_Class_Instances();
                sci.populate_semantic_class_tables(2);
            }
            else if (input.equals("3"))
            {
                Interactions interactions = new Interactions();
                interactions.class_overlap();
            }

            else if (input.equals("4"))
            {
                Interactions interactions = new Interactions();
                interactions.class_overlap_terms();
            }
            else if (input.equals("5"))
            {
                Interactions interactions = new Interactions();
                interactions.class_overlap_mygrid();
            }
            else if (input.equals("5a"))
            {
                Interactions interactions = new Interactions();
                interactions.class_overlap_descriptors();
            }

            else if (input.equals("6"))
            {
                Descriptor_Processor extract_descriptor = new Descriptor_Processor();
                extract_descriptor.extract_nps_from_text_files();
            }
            else if (input.equals("6a"))
            {
                Descriptor_Processor extract_descriptor = new Descriptor_Processor();
                extract_descriptor.extract_top_300_terms();
            }

            else if (input.equals("7"))
            {
                Descriptor_Processor extract_descriptor = new Descriptor_Processor();
                extract_descriptor.load_filtered_descriptors_from_csv_file();
            }

            else if(input.equals("7a"))
            {
                Descriptor_Processor extract_descriptor = new Descriptor_Processor();
                extract_descriptor.export_descriptors_to_bioinformatics_service_descriptors_table();
            }
            else if(input.equals("7b"))
            {
                Descriptor_Processor extract_descriptor = new Descriptor_Processor();
                extract_descriptor.export_to_xml();
            }

            else if(input.equals("8"))
            {
                Descriptors_Ngrams extract_descriptor = new Descriptors_Ngrams();
                extract_descriptor.make_ngrams_service_descriptors();
            }
            else if(input.equals("8a"))
            {
                Descriptors_Ngrams extract_descriptor = new Descriptors_Ngrams();
                extract_descriptor.make_ngrams_sentence_descriptors();
            }
            else if (input.equals("e"))
            {
                System.exit(0);
            }
        }
        catch (Exception ex)
        {
            System.out.println("SQL Exception: Main Menu : " + ex.getMessage());
        }

    }
}
